<?php
header("Content-type:text/html; charset=utf-8");
include_once 'conn/conn.php';
$pagesize=10;
$total = mysql_fetch_array(mysql_query("select count(*) from tb_friend"));//查询数据库中一共有多少条数据 
$Total = $total[0]; // 
$Totalpage = ceil($Total/$pagesize);//上舍，取整 
if(!isset($_GET['page'])||!intval($_GET['page'])||$_GET['page']>$Totalpage||$_GET['page']<1){ 
	$page=1; 
}else { 
	$page=$_GET['page'];//如果不满足以上四种情况，则page的值为$_GET['page'] 
} 
$startnum = ($page-1)*$pagesize;//开始条数 
$sql = "select * from tb_friend order by id limit $startnum,$pagesize";//查询出所需要的条数 
$rs = mysql_query($sql); 
while ($contents = mysql_fetch_array($rs)){
	$result[] = $contents;
}

?> 
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<link rel="stylesheet" href="templets/css/common.css" type="text/css" />
<script type="text/javascript" src="../js/jquery-1.6.2.min.js"></script>
<script type="text/javascript">
$(document).ready(function(){
	$('.tb').hover(function(){
		$(this).css('background','#afe8fd').siblings().css('background','#fff');
	})
})
</script>
<title>文章分类</title>
</head>

<body>
<div id="man_zone">	
	<form action="add_type.php" method="post">
		<table width="80%" border="0" align="center"  cellpadding="1" cellspacing="0" class="table_style">
    		<tr>
    			<td width="10%" class="center nos">ID</td>
      			<td width="30%" class="center nos"><span class="left-title">公司名称</span></td>
      			<td width="40%" class="center nos"><span class="left-title">公司网址</span></td>
      			<td width="20%" class="center nos">操作</td>
    		</tr>
    		<?php 
    			foreach ($result as $type){
    		?>
    		<tr class="tb">
    			<td class="center nos"><?php echo ($type["id"]);?></td>
    			<td class="nos"><?php echo ($type["company"]);?></td>
    			<td class="nos"><?php echo ($type["urls"]);?></td>
    			<td class="center nos"><a href="furls_edit.php?id=<?php echo ($type["id"]);?>">修改</a>&nbsp;&nbsp;|&nbsp;&nbsp;<a href="furls_del.php?id=<?php echo ($type["id"]);?>">删除</a></td>
    		</tr>
    		<?php
    			}
    		?>
    		<tr>
				<td colspan="5" class="nos">
					<?php
					if($total){
						$per = $page - 1;//上一页
						$next = $page + 1;//下一页
						echo "<center>共有".$Total."条记录,每页".$pagesize."条,共".$Totalpage."页 ";
						if($page != 1){
							echo "<a href='".$_SERVER['PHP_SELF']."'>首页</a>";
							echo "<a href='".$_SERVER['PHP_SELF'].'?page='.$per."'> 上一页</a>";
						}
						if($page != $Totalpage){
							echo "<a href='".$_SERVER['PHP_SELF'].'?page='.$next."'> 下一页</a>";
							echo "<a href='".$_SERVER['PHP_SELF'].'?page='.$Totalpage."'> 尾页</a></center>";
						}
					}
					?>
				</td>
			</tr>
		</table>
	</form>
</div>
</body>
</html>